#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define mes(x) memset(x,0,sizeof(x))
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 1e5+10;
const int mod = 1e9+7;

int h[MAXN],cnt,n,col[MAXN];
ll f[MAXN][2];

struct edge{int v,nxt;}e[MAXN<<1];
void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

void dfs(int x){
	f[x][col[x]] = 1;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		dfs(y); if(col[x]) f[x][1] = f[x][1] * (f[y][1] + f[y][0]) % mod;
		else f[x][1] = (f[x][0] * f[y][1] % mod + f[x][1] * f[y][0] % mod + f[x][1] * f[y][1] % mod) % mod,
				 f[x][0] = f[x][0] * (f[y][0] + f[y][1]) % mod;
	}
}

int main (){
	n = in;
	for(int i = 1;i < n;i++) link(in+1,i+1);
	for(int i = 1;i <= n;i++) col[i] = in;
	dfs(1); printf("%lld\n",(f[1][1] ) % mod);
	return 0;
}

